## Title
MPU6050 Motion Sensor

![MPU6050 GY-521 motion sensor module](../../Images/mpu6050_module.jpg)

![MPU6050 motion sensor course pinout](../../Images/mpu6050_pinout_course.svg)

## What It Is
The `MPU6050` is a 6-axis motion sensor with an accelerometer and a gyroscope in one chip.

## What It Does In This Project
- measures motion and tilt
- provides pitch, roll, and yaw-related data
- lets the dashboard show how the board is moving

## Origins And Background
The MPU6050 came from InvenSense and became one of the best-known hobby IMU modules because it was affordable and widely available. It helped bring smartphone-style motion sensing into small projects.

## What A Gyroscope Is
A gyroscope is a device that helps measure or resist rotation.

In older mechanical gyroscopes, a spinning wheel keeps its orientation because of angular momentum. That makes it useful for understanding turning, balance, and direction.

In modern electronic sensors like the MPU6050, there is no big visible spinning wheel. Instead, the chip uses tiny moving structures inside silicon. When the device rotates, those tiny structures experience forces that the chip can measure. That gives us a reading related to rotational speed.

## The Physics Behind A Classic Gyroscope
A spinning object has `angular momentum`. That means it “wants” to keep rotating in the same plane unless something applies a turning force.

This is why a bicycle wheel held by its axle can feel strange when it is spinning. It resists changes in orientation more than when it is still.

Two useful ideas to introduce are:
- `angular momentum` : spinning motion that carries directional stability
- `torque` : a turning force that tries to change the direction of rotation

If a spinning gyroscope is pushed, it does not always move in the obvious direction. Instead, it can show `precession`, where the axis moves at right angles to the applied force. That behaviour made gyroscopes scientifically interesting and very useful for navigation.

## The Physics Behind A MEMS Gyroscope
The MPU6050 uses a `MEMS` gyroscope. MEMS stands for Micro-Electro-Mechanical Systems.

Inside the chip are tiny vibrating structures. When the sensor rotates, those moving parts experience a `Coriolis force`.

A good student-level summary is:
- a tiny part inside the chip is already moving
- if the whole chip rotates, the motion gets deflected slightly
- the chip measures that deflection
- that measured change becomes rotational data

So the modern gyro is not a big spinning wheel. It is a microscopic vibrating system using real physical forces to sense turning.

## Historical Origins Of The Gyroscope
The word `gyroscope` comes from Greek roots meaning something like “rotation” and “to look or observe.” In the 1800s, scientists and engineers used spinning-wheel gyroscopes to study orientation and rotation. Over time, gyroscopes became important in navigation systems for ships, aircraft, spacecraft, and missiles.

So when students see yaw or rotation data on the dashboard, they are touching a modern miniaturised version of a very important navigation technology.

## Accelerometer Vs Gyroscope
The accelerometer helps measure linear acceleration and tilt relative to gravity.

The gyroscope helps measure rotational motion.

Together, they give a better picture of how the board is moving.

## Why Software Is Still Needed
A gyroscope usually reports `rate of rotation`, not a ready-made word like `yaw angle`. To get useful orientation values, software has to process the readings over time and combine them with other sensor information.

That is why motion sensing is both a hardware topic and a software topic.

## How It Communicates
- uses `I2C`
- the Bluepill acts as the controller
- the sensor responds at an address on the shared bus

## Module Pinout
On the common `GY-521` style breakout the usual pins are:

- `VCC` : power
- `GND` : ground
- `SCL` : I2C clock
- `SDA` : I2C data
- `XDA` : auxiliary I2C data, often unused in simple projects
- `XCL` : auxiliary I2C clock, often unused in simple projects
- `AD0` : address select
- `INT` : interrupt output

## Course Wiring
In this course hardware the active pins are:

- `SCL` -> Bluepill `PB10` (`I2C2_SCL`)
- `SDA` -> Bluepill `PB11` (`I2C2_SDA`)
- `INT` -> Bluepill `PB1`
- `VCC` -> sensor supply rail
- `GND` -> common ground

This is a useful note because it shows both the shared two-wire bus and the extra interrupt pin that gives the MCU a more event-driven way to react.

## Why I2C Fits Well Here
I2C is useful when several devices need to share the same two signal wires. It saves pins and keeps wiring simple.

## Physical Layer Notes
I2C uses:
- `SCL` clock line
- `SDA` data line
- pull-up resistors
- open-drain signalling

This is a good place to explain why lines can be shared safely.

## Why It Matters
The MPU6050 turns invisible motion into numbers students can see. That makes it excellent for teaching sensors, data interpretation, and protocols.

## Teaching Focus
- accelerometer vs gyroscope
- angular momentum
- torque and precession
- MEMS gyroscope idea
- raw data vs useful angles
- I2C addressing
- pull-ups and open-drain communication
- gyroscopes as a navigation technology

## Datasheet Navigation Tips
Look for:
- device address
- register map
- power requirements
- measurement ranges
- interrupt pin behaviour

## Interesting Detail
A motion sensor does not directly “know” words like pitch or roll. It measures acceleration and rotation, and software turns those into human-friendly values.

## Good Questions To Ask Students
- Why do we need software interpretation after sensor readings?
- Why is I2C good for sensors?
- What is the difference between measuring tilt and measuring rotation?
- How is an electronic gyroscope different from a classic spinning-wheel one?
- Why can a vibrating chip act like a gyroscope at all?
